#include <string>
#include <cstring>
#include <iostream>
#include <cstdio>
#include <iomanip>

using namespace std;

typedef struct TCard{
	int val;
	char suit;
	int idx;
} TCard;

char valList[] = "A23456789TJQK";

istream& operator>>(istream& in, TCard& x) {
	char c;
	in >> c;
	if (c == '#') {
		x.suit = '#';
		return in;
	}
	in >> x.suit;
	for (int i=0; i<13; ++i)
		if (valList[i] == c) {
			x.val = i+1;
			break;
		}
	return in;
}

TCard deck[60];

TCard piles[4][4];
int pilesCnt[4][4];
int playingIdx;

void showPiles(void) {
	for (int i=0; i<4; ++i) {
		for (int j=0; j<4; ++j)
			if (piles[i][j].suit != ' ')
				cout << valList[piles[i][j].val-1] << piles[i][j].suit << " ";
			else
				cout << "   ";
		cout << endl;
	}
	cout << endl;
}

void reassessing(void) {
	if (playingIdx>=51) return;

	for (int i=0; i<4; ++i) {
		for (int j=0; j<4; ++j)
			if (piles[i][j].suit == ' ' && pilesCnt[i][j]>0) {
				++pilesCnt[i][j];
				piles[i][j] = deck[++playingIdx];
				if (playingIdx>=51) return;
			}
	}
}

int playCard(int idx) {
	bool puton = false;
	for (int i=0; i<4; ++i) {
		for (int j=0; j<4; ++j)
			if (piles[i][j].suit == ' ') {
				piles[i][j] = deck[idx];
				++pilesCnt[i][j];
				puton = true;
				break;
			}
		if (puton) break;
	}

	if (!puton) return -1;
// 	showPiles();
// 

	while (true) {
		int pos[14];
		for (int i=0; i<14; ++i)
			pos[i] = -1;
		for (int i=0; i<4; ++i) {
			for (int j=0; j<4; ++j)
				if (piles[i][j].suit != ' ') {
					if (pos[piles[i][j].val] == -1)
						pos[piles[i][j].val] = i*4+j;
				}
		}
		bool covered = false;
		for (int i=0; i<4; ++i) {
			for (int j=0; j<4; ++j) {
				if (piles[i][j].suit != ' ') {
					if (piles[i][j].val > 10) {
						if (pos[11]!=-1&&pos[12]!=-1&&pos[13]!=-1) {
							piles[pos[11]/4][pos[11]%4].suit = ' ';
							piles[pos[12]/4][pos[12]%4].suit = ' ';
							piles[pos[13]/4][pos[13]%4].suit = ' ';
							covered = true;
						}
					}
					else {
						if (pos[11-piles[i][j].val]!=-1) {
							piles[pos[11-piles[i][j].val]/4][pos[11-piles[i][j].val]%4].suit = ' ';
							piles[pos[piles[i][j].val]/4][pos[piles[i][j].val]%4].suit = ' ';
							covered = true;
						}
					}
				}
				if (covered) break;
			}
			if (covered) break;
		}
		if (!covered) break;
		else reassessing();
	}

// 
// 	showPiles();
	return 0;
}

int main(void)
{
	int testcase = 0;
	while (true) {
		cin >> deck[0];
		if (deck[0].suit == '#') break;
		++testcase;
		for (int i=1; i<52; ++i)
			cin >> deck[i];
		for (int i=0; i<52; ++i) deck[i].idx = i;
		for (int i=0; i<4; ++i)
			for (int j=0; j<4; ++j) {
				piles[i][j].suit = ' ';
				pilesCnt[i][j] = 0;
			}

		int res=0;
		for (playingIdx=0; playingIdx<52; ++playingIdx) {
			res = playCard(playingIdx);
			if (res == -1) {
				cout << setw(3) << right << testcase << ": Overflowed on card no " << playingIdx+1 << endl;
				break;
			}
		}
		if (res!=-1) {
			cout << setw(3) << right << testcase << ":";
			for (int i=0; i<4; ++i) {
				for (int j=0; j<4; ++j)
					if (pilesCnt[i][j] > 0) cout << setw(3) << right << pilesCnt[i][j];
			}
			cout << endl;
		}
	}

	return 0;
}